 #define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
    int X, Y;
    scanf_s("%d %d", &X, &Y);
    int a = X, b = Y;
    if (X < Y)
    {
        int t = X;
        X = Y;
        Y = t;
    }
    int r = X % Y;
    while (r != 0)
    {
        X = Y;
        Y = r;
        r = X % Y;
    }
    printf("%d\n", Y);
    return 0;
}